import request from '@/utils/request'

// 添加知识点
export function addKnowledgePoint(data) {
  return request({
    url: '/api/knowledge-points',
    method: 'post',
    data
  })
}

// 获取所有知识点
export function getKnowledgePoints() {
  return request({
    url: '/api/knowledge-points',
    method: 'get'
  })
}

// 获取分类下的知识点
export function getKnowledgePointsByCategory(categoryId) {
  return request({
    url: `/api/knowledge-points/category/${categoryId}`,
    method: 'get'
  })
}

// 更新知识点
export function updateKnowledgePoint(id, data) {
  return request({
    url: `/api/knowledge-points/${id}`,
    method: 'put',
    data
  })
}

// 删除知识点
export function deleteKnowledgePoint(id) {
  return request({
    url: `/api/knowledge-points/${id}`,
    method: 'delete'
  })
}

// 设置作业知识点
export function setHomeworkKnowledge(homeworkId, knowledgeIds) {
  return request({
    url: `/api/knowledge-points/homework/${homeworkId}`,
    method: 'post',
    data: knowledgeIds
  })
}

// 获取作业知识点
export function getHomeworkKnowledge(homeworkId) {
  return request({
    url: `/api/knowledge-points/homework/${homeworkId}`,
    method: 'get'
  })
} 